package com.tanglon.controller;

import com.tanglon.annotation.BlogLog;
import com.tanglon.constants.SystemConstants;
import com.tanglon.domain.ResponseResult;
import com.tanglon.domain.dto.AddCommentDTO;
import com.tanglon.domain.entity.Comment;
import com.tanglon.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/commentList")
    @BlogLog(businessName = "获取文章评论")
    public ResponseResult commentList(Long articleId,Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemConstants.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }

    @PostMapping
    @BlogLog(businessName = "添加评论")
    public ResponseResult addComment(@RequestBody AddCommentDTO addCommentDTO){
        return commentService.addComment(addCommentDTO);
    }

    @GetMapping("/linkCommentList")
    @BlogLog(businessName = "获取友链评论信息")
    public ResponseResult linkCommentList(Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }
}
